package com.example.itcacp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("cd_project")
public class Project {
    @TableId(type = IdType.AUTO)
    private Long projectId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;
    private String projectName;
    private String description;
    private String path;
    private String property;
    private Long categoryId;
    private String visibility;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;
    private String tags;

    /**
     * 分类；通过categoryId与内容分类建立联系
     * */
    @TableField(exist = false)
    private Category category; // 项目对应的分类
    @TableField(exist = false)
    private User user;
    /**
     * 点赞量：通过点赞表获取数据
     * */
    @TableField(exist = false)
    private Long likes;
    /**
     * 收藏量：通过收藏表获取数据
     * */
    @TableField(exist = false)
    private Long collections;
    /**
     * 浏览量：通过每个用户的浏览历史表获取数，用户删除浏览历史记录时不级联删除文章的浏览量
     * */
    @TableField(exist = false)
    private Long views;
    /**
     * 浏览内容的用户点赞状态
     * */
    @TableField(exist = false)
    private boolean likeStates;
    /**
     * 浏览内容的用户收藏状态
     * */
    @TableField(exist = false)
    private boolean collectStates;
}
